package com.sss.hloster0406;

public class Vehicle {
	protected String name = "汽车";// 车名
	protected int oil = 20;// 油量
	protected int loss = 0;// 车损度
	// 无参构造方法

	public Vehicle() {
		super();
	}

	// 构造方法,指定车名
	public Vehicle(String name) {
		super();
		this.name = name;
	}

	// 获取车名
	public String getName() {
		return name;
	}

	// 获取油量
	public int getOil() {
		return oil;
	}

	// 获取车损度
	public int getLoss() {
		return loss;
	}

	// 加油
	public void addOil() {
		if (oil > 40) { // 如果加油20升则超过邮箱容量，则加到60升即可
			oil = 60;
			System.out.println("邮箱已加满");
		} else { // 加油20升
			oil = oil + 20;
		}
		System.out.println("加油完成！");
	}

	public void show() {
	};

	// 行驶
	public void driver() {
		if (oil < 10) {
			System.out.println("油量不足10升，需要加油！");
		} else {
			System.out.println("正在行驶！");
			oil = oil - 5;
			loss = loss + 10;
		}
	}
}
